package com.zjw.zy.ext

import android.view.ViewGroup
import android.webkit.WebView
import java.net.URL

/**
 * @author     ：zhong.jw
 * @date       ：Created in 2022/12/9 16:01
 * @description：
 */


fun WebView.open(url: String, js: Boolean = false) {
    this.settings.run {
        this.javaScriptEnabled = js
    }
    this.loadUrl(url)
}

fun WebView.release() {
    this.parent?.let {
        (it as? ViewGroup)?.removeView(this)
    }
    this.stopLoading()
    this.settings.javaScriptEnabled = false
    this.clearHistory()
    this.clearView()
    this.removeAllViews()
    this.destroy()
}